import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MachineInfoVO, MachineInfoForm, MachineInfoQuery } from '@/api/agriculture/machineInfo/types';

/**
 * 查询机械信息列表
 * @param query
 * @returns {*}
 */

export const listMachineInfo = (query?: MachineInfoQuery): AxiosPromise<MachineInfoVO[]> => {
  return request({
    url: '/agriculture/machineInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询机械信息详细
 * @param machineId
 */
export const getMachineInfo = (machineId: string | number): AxiosPromise<MachineInfoVO> => {
  return request({
    url: '/agriculture/machineInfo/' + machineId,
    method: 'get'
  });
};

/**
 * 新增机械信息
 * @param data
 */
export const addMachineInfo = (data: MachineInfoForm) => {
  return request({
    url: '/agriculture/machineInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改机械信息
 * @param data
 */
export const updateMachineInfo = (data: MachineInfoForm) => {
  return request({
    url: '/agriculture/machineInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除机械信息
 * @param machineId
 */
export const delMachineInfo = (machineId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/machineInfo/' + machineId,
    method: 'delete'
  });
};
